package com.tamecode.bean.factory;

import com.tamecode.bean.di.Car;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class FactoryBeanTest {
    public static void main(String[] args) {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("bean/scope/beans-factoryBean.xml");
        Car car = (Car) applicationContext.getBean("car1");
        System.out.println(car.toString());
        System.out.println(car.getBrand());

        // 获取 carFactoryBean，需要在ID前面加上 &
        CarFactoryBean carFactoryBean = (CarFactoryBean) applicationContext.getBean("&car1");
        System.out.println(carFactoryBean.toString());
        System.out.println(carFactoryBean.getCarInfo());
        /*
        com.tamecode.bean.di.Car@60c6f5b
        tsla modeY
        com.tamecode.bean.factory.CarFactoryBean@2038ae61
        tsla modeY,200,20000
        */
    }
}
